1 <?
2 $path =
"../images/cat";
3 $pathdb =
"images/cat";
4 if
(isset($_POST['butSaveLoai'])) {
5     $parent=implode(
",",str_replace(",",".",$_POST['txtParent']));
6     $order = $_POST[
'txtSortOrder'];
7     $style = $_POST[
'style'];
8     $link = $_POST[
'link'];
9     
if($order=='') $order=0;
10     
else $order = $_POST['txtSortOrder'];
11     $status=($_POST[
'chkShow']!=''?1:0);
12     $CategoryName= trim($_POST[
'txtName']);
13
14     $err=
"";
15     
if ($CategoryName=="") $err .= "Xin nh&#7853;p tên<br>";
16     $err.=CheckUpload($_FILES[
"txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
17     
18     
if ($err=='')
19     {
20         
if (!empty($_POST['id'])) {
21             $oldid = $_POST[
'id'];
22             $sql =
"update hangsx set name='".$CategoryName."',cat='".$parent."', thutu='".$order."' where id='".$oldid."'";
23         }
else {
24             $sql =
"insert into hangsx (name, cat, thutu) values ('".$CategoryName."','".$parent."','".$order."')";
25         }
26         
if (mysql_query($sql,$con)) {
27             
if(empty($_POST['id'])) $oldid = mysql_insert_id();
28
29             $sqlUpdateField =
"";
30             
31             $extsmall=GetFileExtention($_FILES[
'txtImage']['name']);
32             
if (MakeUpload($_FILES['txtImage'],"$path/hangsx_s$oldid$extsmall"))
33             {
34                 @chmod(
"$path/hangsx_s$oldid$extsmall", 0777);
35                 $sqlUpdateField =
" logo='$pathdb/hangsx_s$oldid$extsmall' ";
36             }
37             
if($sqlUpdateField)
38             {
39                 $sqlUpdate =
"update hangsx set $sqlUpdateField where id='".$oldid."'";
40                 mysql_query($sqlUpdate,$con);
41             }
42         }
43         
else {
44             $err =
"<p align=center class='err'>Không th&#7875; c&#7853;p nh&#7853;t</p>";
45         }
46     }
47     
if ($err=='') echo "<script>window.location='index.php?act=hangsx&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
48     
else echo '<p align=center class="err" style="line-height: 150%">'.$err.'</p>';
49 }
50 ?>
51 <?
52     
if (isset($_GET['id'])) {
53         $oldid=$_GET[
'id'];
54         $sql =
"select * from hangsx where id='".$oldid."'";
55         
if ($result = mysql_query($sql,$con)) {
56             $row=mysql_fetch_array($result);
57             $CategoryName=$row[
'name'];
58             $image=$row[
'logo'];
59             $parent = explode(
",", $row['cat']);
60             $order=$row[
'thutu'];
61             $date=$row[
'date'];
62         }
63     }
64 ?>
65
66 <form method=
"POST" name="FormLoaiSP" enctype="multipart/form-data" action="index.php">
67 <input type=hidden name=
"act" value="hangsx_m">
68 <input type=hidden name=
"oldid" value="<? echo $oldid; ?>">
69 <input type=hidden name=
"page" value="<? echo $_REQUEST['page']; ?>">
70 <input type=hidden name=
"cat" value="<? echo $_REQUEST['cat']; ?>">
71 <input type=
"hidden" name="id" value="<? echo $_REQUEST['id']; ?>">
72 <table border=
"1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
73   <tr>
74     <td width=
"45%" align="center" class="title" height="20">Thêm m&#7899;i / C&#7853;p nh&#7853;t : Hang SX</td>
75   </tr>
76   <tr>
77     <td width=
"45%">
78     <table border=
"0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
79       <tr>
80         <td width=
"15%" class="smallfont">
81         <p align=
"right">Tên hang</td>
82         <td width=
"1%" class="smallfont">
83         <font color=
"#FF0000">*</font></td>
84         <td width=
"83%" class="smallfont">
85         <INPUT
value="<? echo $CategoryName; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
86       </tr>
87       <tr>
88         <td width=
"15%" class="smallfont">
89         <p align=
"right">Hình Icon</td>
90         <td width=
"1%" class="smallfont" align="center">
91         &nbsp;</td>
92         <td width=
"83%" class="smallfont">
93         <INPUT TYPE=
"file" NAME="txtImage" CLASS=textbox size="34"></td>
94       </tr>
95       <tr>
96         <td width=
"15%" class="smallfont">
97         <p align=
"right">Thu&#7897;c danh m&#7909;c</td>
98         <td width=
"1%" class="smallfont">
99         &nbsp;</td>
100         <td width=
"83%" class="smallfont">
101 <?
102         $cats=GetListCat(
17);
103         $parent=explode(
",",$row['cat']);
104         
foreach($cats as $indx => $value)
105         {
106             
if (in_array($cats[$indx][0], $parent))
107                 echo
"<input value=".$cats[$indx][0]." type='checkbox' checked name='txtParent[]'>".$cats[$indx][1]."<br/>";
108             
else
109                 echo
"<input value=".$cats[$indx][0]." type='checkbox' name='txtParent[]'>".$cats[$indx][1]."<br/>";
110         }
111 ?>
112         
113 </td>
114       </tr>
115     
116       <tr>
117         <td width=
"15%" class="smallfont" align="right">
118         Th&#
7913; t&#7921; s&#7855;p x&#7871;p</td>
119         <td width=
"1%" class="smallfont" align="right">
120         &nbsp;</td>
121         <td width=
"83%" class="smallfont">
122         <INPUT
value="<? echo $order; ?>" TYPE="text" NAME="txtSortOrder" CLASS=textbox size="34"></td>
123       </tr>
124       <tr>
125         <td width=
"15%" class="smallfont">
126         <p align=
"right">
127         <INPUT TYPE=
"submit" NAME="butSaveLoai" VALUE="C&#7853;p nh&#7853;t" CLASS=button>&nbsp;</td>
128         <td width=
"1%" class="smallfont">
129         &nbsp;</td>
130         <td width=
"83%" class="smallfont"><p align="left">&nbsp;<INPUT TYPE="reset" CLASS=button value="Nh&#7853;p l&#7841;i"></td>
131       </tr>
132     </table>
133     </td>
134   </tr>
135   </table>
136 </form>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.915 lượt xem

Gõ tìm kiếm nhanh...